package com.sqx.modules.app.controller.app.apple;
import com.braintreegateway.*;

import java.math.BigDecimal;

public class Test2 {
    public static void main(String[] args) {
        // 设置 Braintree 的环境和密钥
        BraintreeGateway gateway = new BraintreeGateway(
                Environment.SANDBOX,
                "your_merchant_id",
                "your_public_key",
                "your_private_key"
        );

        try {
            // 创建交易请求
            TransactionRequest request = new TransactionRequest()
                    .amount(new BigDecimal("10.00"))
                    .paymentMethodNonce("your_payment_method_nonce")
                    .type(Transaction.Type.SALE);

            // 发起交易
            Result<Transaction> result = gateway.transaction().sale(request);

            if (result.isSuccess()) {
                Transaction transaction = result.getTarget();
                System.out.println("支付成功：交易 ID = " + transaction.getId());
            } else {
                System.out.println("支付失败：" + result.getMessage());
            }
        } catch (Exception e) {
            System.out.println("发生错误：" + e.getMessage());
        }
    }
}
